'use strict';
module.exports = (app) => {
  // 购物车表
  const { INTEGER } = app.Sequelize;
  const ShoppingCart = app.model.define('s_shopping_cart', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user_id: INTEGER,
    goods_id: {
      type: INTEGER,
      comment: '商品id',
    },
    project_id: {
      type: INTEGER,
      comment: '项目id',
      allowNull: false,
    },
    num: {
      type: INTEGER,
      comment: '商品数量',
      allowNull: false,
    },
  });

  ShoppingCart.associate = function () {
    // 多对一链接商品表
    app.model.Tables.Shop.ShoppingCart.belongsTo(app.model.Tables.Shop.Goods, {
      foreignKey: 'goods_id',
    });
  };

  return ShoppingCart;
};
